{include file="public/header" /}

<!--<div class="wrapper wrapper-content">-->
<div class="row">
    <div class="col-sm-12">
        <div class="ibox float-e-margins">

            <div class="ibox-content">
                <form method="get" class="form-horizontal" id="form1">
                    <div class="form-group">
                        <label class="col-sm-2 control-label">{:lang('admin role')}</label>
                        <div class="col-sm-10">
                            <select class="form-control m-b" name="roleID" id="roleID">
                                <option value="0">{:lang('please select')}</option>
                                {volist name="roles" id="v"}
                                <option value="{$v.id}">{$v.roleName}</option>
                                {/volist}
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">{:lang('admin name')}</label>
                        <div class="col-sm-10">
                            <input name="adminName" type="text" class="form-control"
                                   value="{$adminInfo.adminName}">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">{:lang('admin password')}</label>
                        <div class="col-sm-10">
                            <input name="adminPwd" type="text" class="form-control" placeholder="{:lang('do not change by input nothing')}"
                                   value="">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">{:lang('admin avatar')}</label>
                        <div class="col-sm-10" onclick="GetUploadify(1,'','admin-admin_avatars','call_back');">
                            <img id="img_holder" src="{$adminInfo.adminAvatar|default='__ROOT__/static/default_head.jpg'}"
                                 width="100" height="100">
                            <input name="adminAvatar" id="img_src" type="hidden"
                                   value="{$adminInfo.adminAvatar}">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">{:lang('admin phone')}</label>
                        <div class="col-sm-10">
                            <input name="adminPhone" type="text" class="form-control"
                                   value="{$adminInfo.adminPhone}">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">{:lang('admin email')}</label>
                        <div class="col-sm-10">
                            <input name="adminEmail" type="text" class="form-control"
                                   value="{$adminInfo.adminEmail}">
                        </div>
                    </div>

                    <input type="hidden" name="adminID" value="{$adminInfo.id}">
                    <div class="hr-line-dashed"></div>
                    <div class="form-group">
                        <div class="col-sm-4 col-sm-offset-2">
                            <button class="btn btn-primary" type="button" onclick="doSubmit()">{:lang('edit')}</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<!--</div>-->

{include file="public/footer" /}
<script>
    $('#roleID').val('{$adminInfo.roleID}');
    function call_back(fileurl_tmp) {
        $("#img_src").val(fileurl_tmp);
        $("#img_holder").attr('src', fileurl_tmp);
    }
    function doSubmit() {
        $.ajax({
            url: "{:U('Admin/editAdmin')}",
            type: 'post',
            data: $('#form1').serialize(),
            dataType: 'JSON',
            success: function (data) {
                if (data.status == 1) {
                    layer.msg(data.msg);
                    setTimeout(function () {
                        // location.reload();
                        parent.location.reload();
                    }, 1000)
                } else {
                    layer.msg(data.msg);
                }
            }
        });
        return false;
    }
</script>
